package com.zzyl.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.entity.Reservation;
import com.zzyl.vo.TimeCountVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ReservationMapper extends BaseMapper<Reservation> {

    //查询取消预约数量
    @Select("select count(*) from app_reservation where update_by =#{updateBy} and status = 2 and update_time between #{begin } and #{end }")
    int getCancelCount(Long updateBy, DateTime begin, DateTime end);

    //查询剩余预约次数
    @Select("select time ,6-count(1) as count from app_reservation where status != 2 and time between #{begin } and #{end } group by time")
    List<TimeCountVo> getRemainingCount(LocalDateTime begin, LocalDateTime end);
}
